<?php 
	$host = "127.0.0.1";
	$userName = "root";
	$pwd = "root";
	$dbName = "text";
	$dbms='mysql';
	$dsn="$dbms:host=$host;dbname=$dbName";
	try {
		$db = new PDO($dsn,'root','root');
		//echo "连接成功。";
	} catch (Exception $exc) {
		//echo $exc->getMassage();
	}
	$db->query('set names utf8');
	if ($_POST["check"]==2) {
		$sql = "SELECT * FROM `class`";
	}elseif ($_POST["check"]==0) {
		$sql = "SELECT * FROM `class` where `checkId` = 0";
	}elseif ($_POST["check"]==1){
		$sql = "SELECT * FROM `class` where `checkId` = 1";
	}
	$result = $db->query($sql);
	$result->setFetchMode(PDO::FETCH_ASSOC);
	$str = "";
	while($row=$result->fetch()){
		if($row['checkID']==0){
			$check = "未安排";
			$set="<th><button  onclick='editDetail(".$row['id'].");'>编辑</button><button onclick='del(".$row['id'].");'>删除</button></th>";
		}else{
			$check = "已安排";
			$set="<th><button  onclick='getDetail(".$row['id'].");'>查看</button><button onclick='del(".$row['id'].");'>删除</button></th>";
		}
		$str .= "
 			<tr>
  				<th>".$row['name']."</th>
  				<th>".$row['tea']."</th>
				<th>".$check."</th>".$set."
 			</tr>";
	}
	exit($str);
?>